<?php
class ProductController extends Controller {

    public function actionDetail($url) {

        $model = Posts::model()->findByPk((int) $url);
        $contact_model=new ContactForm();

        if ($model == NULL) {
            $this->render('error');
            Yii::app()->end();
        }

        $criteria = new CDbCriteria();
        $criteria->limit = '9';
        $criteria->condition = 'cat_id=' . $model->cat_id;

        $model_relation = Posts::model()->findAll($criteria);

        $this->pageTitle = $model->title . ' | ' . Yii::app()->name;
        Yii::app()->clientScript->registerMetaTag($model->description, 'description');
        Yii::app()->clientScript->registerMetaTag($model->keywords, 'keywords');

        $this->render('detail', array(
            'model' => $model,
            'model_relation' => $model_relation,
            'contact_model'=>$contact_model
        ));
    }

    public function filters() {
        return array(
            'accessControl', // perform access control for CRUD operations
            'postOnly + delete', // we only allow deletion via POST request
        );
    }

}